﻿/*******************************************************************************
 * AAEngine
 * Copyright (c) 2010 Mike Jarosch
 *
 * Original source PushButton Engine:
 * Copyright (C) 2009 PushButton Labs, LLC
 * For more information see http://www.pushbuttonengine.com
 *
 * This file is licensed under the terms of the MIT license, which is included
 * in the "MIT License.txt" file at the root directory of this SDK.
 ******************************************************************************/

using Microsoft.Xna.Framework;
using Box2D.XNA;
using AAEngine.Engine.Core;

namespace AAEngine.Box2D
{
    public class CollisionEvent : Event
    {
        public static readonly string COLLISION_EVENT = "AAEngine.Box2D.CollisionEvent.COLLISION_EVENT";
        public static readonly string COLLISION_STOPPED_EVENT = "AAEngine.Box2D.CollisionEvent.COLLISION_STOPPED_EVENT";

        public Box2DSpatialComponent Collider { get; protected set; }

        public Box2DSpatialComponent Collidee { get; protected set; }

        public Vector2 Normal { get; protected set; }

        public Contact Contact {get; protected set; }

        public CollisionEvent(string type, Contact contact)
            : base(type)
        {
            Manifold manifold;
            contact.GetManifold(out manifold);
            Collider = contact.GetFixtureA().GetUserData() as Box2DSpatialComponent;
            Collidee = contact.GetFixtureB().GetUserData() as Box2DSpatialComponent;
            Normal = manifold._localNormal;
            Contact = contact;
        }
    }
}
